package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

import AD.BDRol;

public class VistaNuevoRol extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private String valor;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VistaNuevoRol frame = new VistaNuevoRol("asd");
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public VistaNuevoRol(String textoLabel) {
		setTitle(textoLabel);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 245, 131);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textField = new JTextField();
		textField.setBounds(81, 24, 130, 20);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblNuevoRol = new JLabel(textoLabel);
		lblNuevoRol.setBounds(10, 27, 61, 14);
		contentPane.add(lblNuevoRol);
		
		JButton btnAceptar = new JButton("Aceptar");
		btnAceptar.setBounds(122, 55, 89, 23);
		contentPane.add(btnAceptar);
		btnAceptar.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				 valor=textField.getText();
				if(valor!=""){
					firePropertyChange("nuevoValor", true, true);
					dispose();
				}
			}
		});
	}
	public String getValor(){
		return valor;
	}
}
